package com.sh.data.engine.application.model.request.normalization;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author binghe
 * @email binghe.yxh@xuelangyun.com
 */
@Data
@Schema
public class DictionaryRequest {

    /**
     * 主键
     */
    @Schema(description = "主键id")
    private Long id;

    /**
     * 字典名称（中文）
     */
    @Schema(description = "字典名称（中文）", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "中文名称不能为空")
    @Length(max = 128, message = "中文名称最长128个字符")
    @Pattern(regexp = "[\\w\\s\\S]{1,128}", message = "中文名称不合法")
    private String dictNameCn;

    /**
     * 字典名称（英文）
     */
    @Schema(description = "字典名称（英文）", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "英文名称不能为空")
    @Length(max = 128, message = "英文名称最长128个字符")
    @Pattern(regexp = "[a-zA-Z0-9_]{1,128}", message = "英文名称不合法")
    private String dictNameEn;

    /**
     * 字典分组id
     */
    @Schema(description = "字典分组id", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "字典分组id不能为空")
    private Long dictDirId;

    /**
     * 字典类型 0自建 1引用
     */
    @Schema(description = "字典类型 0自建 1引用", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "字典类型不能为空")
    @Range(min = 0, max = 1, message = "字典类型 0自建 1引用")
    private Integer dictType;

    @Schema(description = "发布状态 1已发布 0未发布", required = false)
    @Range(min = 0, max = 1, message = "发布状态 1已发布 0未发布")
    private Integer releaseStatus;

    /**
     * 业务定义（备注）
     */
    @Schema(description = "业务定义")
    @Length(max = 128, message = "业务定义最多128个字符")
    private String remark;

    /**
     * 引用字典id
     */
    @Schema(description = "引用字典id")
    private Long pid;

    /**
     * 归属部门id
     */
    @Schema(description = "归属部门id")
    private Long departmentId;

    /**
     * 数据类型
     */
    @Schema(description = "数据类型")
    private String dictDataType;

    /**
     * 数据长度
     */
    @Schema(description = "数据长度")
    @Range(min = Integer.MIN_VALUE, max = Integer.MAX_VALUE)
    private Integer dictDataLength;

    /**
     * 数据精度
     */
    @Schema(description = "数据精度")
    private Integer dictDataPrecision;

    /**
     * 度量单位
     */
    @Schema(description = "度量单位")
    private String dictDataUnit;

    /**
     * 允许为空 0-否 1-是
     */
    @Schema(description = "允许为空 0-否 1-是")
    @Range(min = 0, max = 1, message = "是否为空 0-否 1-是")
    private Integer allowNull;

    /**
     * 允许重复 0-否 1-是
     */
    @Schema(description = "允许重复 0-否 1-是")
    @Range(min = 0, max = 1, message = "允许重复 0-否 1-是")
    private Integer allowDuplicate;

    /**
     * 取值范围json
     */
    @Schema(description = "取值范围json")
    private String dictDataRangeJson;

    /**
     * 正则表达式
     */
    @Schema(description = "正则表达式")
    private String dictDataPattern;

    /**
     * 枚举值json
     */
    @Schema(description = "枚举值json")
    private String dictDataEnumValueJson;

    /**
     * 业务属性json
     */
    @Schema(description = "业务属性json")
    private String bizPropertiesJson;
}
